Explaining the SampleClientAPI Code

This topic further explains the sample code and its parts.

The sample code is divided into five major parts.
  1. Authentication/Login
  2. Calling the Advance Calendar Process
  3. Calling the Actual Cost Integration
  4. Running the Update Totals
  5. Retrieving the Process Logs

Authentication/Login

You can login to the Cobra Web Service by creating an instance of CobraServices Class class that provides a mechanism to consume the Cobra Web Service host. CobraServices.ServiceIdentityData Property contains the Username, SecurePassword, and Datasource of the Cobra user. Datasource is required if Cobra is configured in a standalone or server-deployment environment and has multiple data sources. After setting up the ServiceIdentityData, you can now call the CobraServices.Login Method. This authenticates the user and transitions the state to the Opened state.

Advance Calendar

You can run advance the calendar by creating an instance of ProjectOperations Class using the CobraServices.CreateServiceOperations Method. The ProjectOperations class has operations related to project like AdvanceCalendar, CalculateProgress, CopyProject, and so on. To advance a calendar, create an instance of AdvanceCalendarServiceArguments Class by calling the ProjectOperations.CreateProjectOperationsServiceArguments Method and set the options like Project, IncludeForecastInUpdateTotals, Log, and so on. Then, you can call the ProjectOperations.AdvanceCalendar Method and pass the AdvanceCalendarServiceArguments instance you have created. This will run the Advance Calendar with the options you have set and return a ServiceResult Class. The CheckResult method will check and print the data from the ServiceResult in the console.

Integrate Actual Costs

You can run integrate actual cost by creating an instance of Integration Class using the CobraServices.CreateServiceOperations Method. The Integration class has operations related to integration like IntegrateActualCosts, IntegrateProjectData, and so on. To integrate actual costs, create an instance of IntegrateActualCostsServiceArguments Class by calling the Integration.CreateIntegrationServiceArguments Method and set the options like ConfigurationName, DatabaseTable, ConnectionName, and so on. Then, you can call the Integration.IntegrateActualCosts Method and pass the IntegrateActualCostsServiceArguments instance you have created. This will run the Integrate Actual Costs with the options you have set and return a ServiceResult Class. The CheckResult method will check and print the data from the ServiceResult in the console.

Update Totals

You can run update totals by creating an instance of ProjectOperations Class using the CobraServices.CreateServiceOperations Method. The ProjectOperations class has methods related to operations of a project like UpdateTotals, CalculateProgress, AdvanceCalendar, and so on. To update totals, create an instance of UpdateTotalsServiceArguments Class by calling the ProjectOperations.CreateProjectOperationsServiceArguments Method and set the options like Project, Log, and so on. Then, you can call the ProjectOperations.UpdateTotals Method and pass the UpdateTotalsServiceArguments instance you have created. This will run the Update Totals with the options you have set and return a ServiceResult Class. The CheckResult method will check and print the data from the ServiceResult in the console.

Retrieve Process Logs

You can retrieve process logs by creating an instance of ProcessLogOperations Class using the CobraServices.CreateServiceOperations Method. The ProcessLogsOperations class has operations related to processing logs like GetProcessLogs. To retrieve the process logs, create an instance of ProcessLogFilter Class by calling the ProcessLogOperations.CreateProcessLogFilter Method and set the options like Project, Context, DateRange, and so on. Then, you can call the ProcessLogOperations.GetProcessLogs Method and pass the ProcessLogFilter instance you have created. This will return an IEnumerable< ProcessLog>.